//
//  RegistViewController.m
//  XIWenLeJian
//
//  Created by lanou3g on 15/11/16.
//  Copyright © 2015年 蓝足. All rights reserved.
//

#import "RegistViewController.h"
#import <AVOSCloud/AVOSCloud.h>
#import "LoginViewController.h"

@interface RegistViewController ()

@end

@implementation RegistViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor groupTableViewBackgroundColor];
    self.title = @"注册页面";
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"nav_chbackbtn"] style:(UIBarButtonItemStylePlain) target:self action:@selector(back)];
    [self.navigationItem.leftBarButtonItem setTintColor:[UIColor whiteColor]];
}

- (void)back
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (IBAction)backToLogin:(id)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (IBAction)registBT:(id)sender {
    
    AVUser *user = [AVUser user];
    user.username = _userNmaeTextFeld.text;
    
    user.password = _possWordTextFeld.text;
    
    user.email = _emailTextFeld.text ;
    
    [user signUpInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
        if (succeeded) {
            
            UIAlertView*aler = [[UIAlertView alloc] initWithTitle:@"提示" message:@"注册成功跳转到登陆页面" delegate:self cancelButtonTitle:@"确定" otherButtonTitles: nil];
            
            [aler show];
            [self.navigationController popViewControllerAnimated:YES];
        }else{
            
            UIAlertView*aler = [[UIAlertView alloc] initWithTitle:@"提示" message:@"注册失败" delegate:self cancelButtonTitle:@"确定" otherButtonTitles: nil];
            
            [aler show];
            
        }
    }];

    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
